function P = cart2pol(C,O)
% Convert from cartesian to spherical coordinates, return angles in
% radians.
X = C - repmat(O, size(C,1), 1);
P(:,1) = sqrt(sum(X.^2, 2)); % range
P(:,2) = atan2(X(:,2), X(:,1)); % azimuth - measured from x axis
end